package com.eight.cloud.payment.service.impl;

import com.eight.cloud.openapi.annotations.OpenApi;
import com.eight.cloud.openapi.interfaces.LogRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName: LogRecordServiceImpl
 * @Author: TXC
 * @Date: 2024-11-15 15:12
 **/
@Slf4j
@Service
public class LogRecordServiceImpl implements LogRecordService {
    @Override
    public void doSuccess(HttpServletRequest request, OpenApi annotation, String body, Class<?> controller) {
        log.info("{} {} {} {} {}", request.getMethod(), request.getRequestURI(), request.getQueryString(), body, "success");
        LogRecordService.super.doSuccess(request, annotation, body, controller);
    }

    @Override
    public void doBefore(HttpServletRequest request, OpenApi annotation, String body, Class<?> controller) {
        log.info("{} {} {} {} {}", request.getMethod(), request.getRequestURI(), request.getQueryString(), body, "before");
        LogRecordService.super.doBefore(request, annotation, body, controller);
    }

    @Override
    public void doException(HttpServletRequest request, OpenApi annotation, String body, Class<?> controller, Exception e) {
        log.info("{} {} {} {} {}", request.getMethod(), request.getRequestURI(), request.getQueryString(), "exception", e.getMessage());
        LogRecordService.super.doException(request, annotation, body, controller, e);
    }
}
